<template>
    <div class="header">
        <div @click="goBack"><van-icon name="arrow-left" /></div>
        <div>{{ name }}</div>
        <div><van-icon name="ellipsis" />123456789</div>
    </div>
    <div class="block"></div>
</template>

<script>
import { useRouter } from 'vue-router';
export default{
    name: "Header",
    props: {
        name:{
            type: String,
            default: "",     // 创建组件通信？？？
        },
        back: {
            type: String,   // ?????
        },
    },

    setup(props, content){
        console.log(content);
        const router = useRouter();
        const goBack = () => {
            if (props.back) {
                router.push({
                    path: props.back,
                });
            } else {
                router.go(-1);
            }
        };
        
        return {
            goBack,
        };
    },
};
</script>

<style lang="less" scoped>
.header{
    width: 100%;
    height: 3rem;
    background: white;
    display: flex;
    position: fixed;
    top: 0;
    align-items: center;
    z-index: 1000;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0 0.4rem;
    h3 {
        line-height: 3rem;
    }
}
.block{
    height: 3rem;
}
</style>